<!-- Home Page Slider -->
<?php 
	$storeId = Mage::app()->getStore()->getId();
	$today = date("Y-m-d");
    $banners = Mage::getModel('bannerslider/banner')->getCollection()
    		->addFieldToSelect('*')
            ->setStoreId($storeId)
            ->addFieldToFilter('status', 0)
            ->addFieldToFilter('bannerslider_id', 2)
            ->addFieldToFilter('start_time', array('lteq' => $today))
            ->addFieldToFilter('end_time', array('gteq' => $today))
            ->setOrder('order_banner', "ASC");

    $banners->getSelect()->join(array('table_alias' => $banners->getTable('bannerslider/value')), 'main_table.banner_id = table_alias.banner_id And table_alias.store_id = '.$storeId);
    $banners->getSelect()->group("main_table.banner_id");
 ?>
 <style type="text/css">
 	.messages{display: none;}
 </style>
<div class="row flexslider banner">
	<ul class="slides">
		<?php foreach($banners as $banner): ?>
			<li style="background: <?php echo $banner['image_alt'] ?>;">
				<a href="<?php echo $banner['click_url']?>"><img  src="<?php echo Mage::helper('bannerslider')->getBannerImage($banner['image']);?>"/></a>
			</li>
		<?php endforeach ?>
	</ul>
	<script type="text/javascript">
		$(document).ready(function(){
			//BannerSlider Right Image 
			if($(document.body).width() !== 1583 || $(document.body).width() >1200)
			{
				var addWidth = ($(document.body).width() - $('.section-1').width())/2;
				$('.banner-sale').css({
					right:addWidth,
				});
			}

			$(window).resize(function(){
				var addWidth = ($(document.body).width() - $('.section-1').width())/2;
				var scrollWidth = $('.category-product').offset().left;
				$('.banner-sale').css({
					right:addWidth,
				});
				$rightnav=$('.right-nav');
				if(scrollWidth >= 132)
				{
					$rightnav.fadeIn();
				}else{
					$rightnav.fadeOut();
				}
			})
			//banner
			if($(".flexslider").length!=0){

				$(".flexslider").flexslider({
					animation: "fade",
					slideshowSpeed: 4500,
					slideshow: true,
					animationDuration: 5500,
					directionNav: false,
					slideshow: true,
					controlNav: true
				});
				$(".sysad").flexslider({
					animation: "fade",
					slideshow: true,
					directionNav: false,
					slideshow: true,
					controlNav: true
				});

				$(".category-ad").flexslider({
					animation: "fade",
					slideshow: true,
					directionNav: false,
					slideshow: true,
					controlNav: true
				});
			}
		})

		//右浮动块
		$(document).scroll(function(){
			var scrollWidth = $('.category-product').offset().left;
			var scrolltop=$(window).scrollTop(),$rightnav=$('.right-nav');
			if(scrolltop > 150 && scrollWidth >= 132){
				$rightnav.fadeIn();
			}else{
				$rightnav.fadeOut();
			}
		})
	</script>
	<!-- This Need Static Block -->
	<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('pc_right_sale')->toHtml() ?>
</div>

<!-- Main Content -->
<?php echo $this->getChildHtml('home_sales') ?>
<!-- Catagory Products -->
<?php echo $this->getChildHtml('home_category_products') ?>
</div>